package com.xudow.app.dynamicstate_old.module.user;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.jude.beam.expansion.BeamBaseActivity;
import com.xudow.app.R;

import butterknife.OnClick;
import io.rong.imkit.fragment.ConversationFragment;

/**
 * Created by zhuchenxi on 15/7/21.
 */
public class ChatActivity extends BeamBaseActivity {
    String id;
    String title;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_chat);
        id = getIntent().getData().getQueryParameter("targetId");
        title = getIntent().getData().getQueryParameter("title");
        ((TextView) findViewById(R.id.tv_title)).setText(title);
        findViewById(R.id.image_back).setOnClickListener(v -> finish());
        ConversationFragment fragment = (ConversationFragment) getSupportFragmentManager().findFragmentById(R.id.conversation);
        if (fragment != null) {
            fragment.setUri(getIntent().getData());
            findViewById(R.id.image_person).setOnClickListener(v -> {
                Intent i = new Intent(this, UserProfileActivity.class);
                i.putExtra(UserProfileActivity.USER_PROFILE_ID, Long.parseLong(id));
                startActivity(i);
            });
        } else {
            finish();
        }
    }
}
